#include "StdAfx.h"

#include "Integrator.h"
#include "RadaWrapper.h"
#include "LeapFrogIntegrator.h"

CIntergator::CIntergator(WorkType eType)
: m_nVarCount(3)
{
	switch(eType)
	{
	case eEverhard:
		{
			IRadaParamInterface prmRada;
			{
				prmRada.m_NCLASS = -2;
				prmRada.m_NOR = 15;
				prmRada.m_LL = 10;
				prmRada.m_NI = 2;
				prmRada.m_NV = m_nVarCount;
				prmRada.m_XL = (float)1.0e-9;
				prmRada.m_dIntegrationStep = 10;
			}
			m_pImpl = auto_ptr<IIntegratorInterface>(new CRadaWrapper(prmRada));
		}
		break;
	case eLeapFrog:
		{
			m_pImpl = auto_ptr<IIntegratorInterface>(new CLeapFrogIntegrator(m_nVarCount));
		}
		break;
	default:
		CCustomException(_T("Unknoun type of integrator"));
	}
}

bool CIntergator::MoveTR(double tStart, double tEnd, double *x, double *v, IForceInterface *pForce)
{
	return m_pImpl->Move(tStart, tEnd, x, v, pForce);
}

bool CIntergator::Move(double tStart, double tEnd, double *x, double *v, IForceInterface *pForce)
{
	bool bRes = MoveTR(tStart, tEnd, x, v, pForce);
	return bRes;
}

